<script>
jQuery(document).ready(function($){	

	$("#related_concept").attr("value", '<?php echo $question->related_concept?>');
	$("#answer_correct").attr("value", <?php echo $question->answer_correct?>);

	$("#edit").click(function(){
		$.blockUI({ message: $('<p style="font-size:15px;">Aguarde Carregando...</p>') });
		$("#title").html("EDIÇÃO");
		$("#related_concept").removeAttr("disabled");
		$("#question").removeAttr("disabled");
		$("#answer_1").removeAttr("disabled");
		$("#answer_2").removeAttr("disabled");
		$("#answer_3").removeAttr("disabled");
		$("#answer_4").removeAttr("disabled");
		$("#answer_5").removeAttr("disabled");
		$("#answer_correct").removeAttr("disabled");
		$("#submit").removeAttr("disabled");
		$.unblockUI();
	});

	$("#delete").click(function() {
		var url = '<?php echo WWW_APP.'questions/delete/unit/'.$question->unitid.'/question/'.$question->id?>';
		window.location.href= url;
	});

	$("#cancel").click(function() {
		//$.blockUI({ message: $('<p style="font-size:15px;">Aguarde Carregando...</p>') });
		var url = '<?php echo WWW_APP.'questions/index/unit/'.$question->unitid?>';		
		window.location.href= url;		
	});
		
});
</script>
<script type="text/javascript" src="<?php echo WWW_ROOT.'js/validate.js'?>"></script>

<div id="question_visualize">
<!-- 
	<div id="questions_list" class="units">
		<h2><?php echo "Unidade: ".$unit?></h2>
		<br /><br />		
		<?php 
		if(!isset($questions_list)) {
			echo "Não existe perguntas no banco de dados.";
		}
		?>
		<ul>
			<?php 
			foreach($questions_list as $key=>$value):			
			?>
				<li><a href="<?php echo WWW_APP.'questions/visualize/unit/'.$value->unitid.'/question/'.$key?>"><?php echo $value->question?></a></li>
			<?php 	
			endforeach;
			?>
		</ul>
	</div>

 	
	<input type="button" id="edit" value="Editar" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"/>
-->

	<form id="question_form" method="post" action="<?php echo WWW_APP.'questions/edit/question/'.$question->id?>">
		
		<!-- 
		<h1 id="title">VISUALIZAÇÃO</h1>	
		<br /><br />
		 -->
		 
		<label>Conceito relacionado: <span class="red">*</span></label>
		<select id="related_concept" name="related_concept" disabled="disabled" class="ui-widget ui-state-default ui-corner-all">
			<?php foreach($concepts as $key=>$concept):?>
				<option value="<?php echo $key?>"><?php echo $concept;?></option>
			<?php endforeach;?>
		</select>		
		<br /><br />
		
		<label>Pergunta <span class="red">*</span></label>
		<br />
		<textarea id="question" name="question" rows="8" cols="50" class="ui-widget-content ui-corner-all"><?php echo $question->question?></textarea>
		<br /><br />
		
		<label>Resposta 1 <span class="red">*</span></label>
		<br />
		<textarea id="answer_1" name="answer_1" rows="4" cols="50" class="ui-widget-content ui-corner-all"><?php echo $question->answer_1?></textarea>
		<br /><br />
		
		<label>Resposta 2 <span class="red">*</span></label>
		<br />
		<textarea id="answer_2" name="answer_2" rows="4" cols="50" class="ui-widget-content ui-corner-all"><?php echo $question->answer_2?></textarea>
		<br /><br />
		
		<label>Resposta 3 <span class="red">*</span></label>
		<br />
		<textarea id="answer_3" name="answer_3" rows="4" cols="50" class="ui-widget-content ui-corner-all"><?php echo $question->answer_3?></textarea>
		<br /><br />
		
		<label>Resposta 4 <span class="red">*</span></label>
		<br />
		<textarea id="answer_4" name="answer_4" rows="4" cols="50" class="ui-widget-content ui-corner-all"><?php echo $question->answer_4?></textarea>
		<br /><br />
		
		<label>Resposta 5 <span class="red">*</span></label>
		<br />
		<textarea id="answer_5" name="answer_5" rows="4" cols="50" class="ui-widget-content ui-corner-all"><?php echo $question->answer_5?></textarea>
		<br /><br />
		
		<label>RESPOSTA CORRETA: <span class="red">*</span></label>
		<select id="answer_correct" name="answer_correct" class="ui-widget ui-state-default ui-corner-all">
			<option value="">Escolha a reposta</option>
			<option value="1">Resposta 1</option>
			<option value="2">Resposta 2</option>
			<option value="3">Resposta 3</option>
			<option value="4">Resposta 4</option>
			<option value="5">Resposta 5</option>
		</select>
		<br /><br /><br />
		
		<input id="submit" type="submit" value="Salvar" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only">
		<input type="button" id="delete" value="Excluir" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"/>
		<input id="cancel" type="button" value="Cancelar" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only">
	
	</form>
	
</div>
